<?php
/*
 * Created on May 29, 2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

require_once ('db/DBManager.php');
require_once ('db/ArchiveLinkLoader.php');
DBManager :: getInstance();
$contentLoader = new ArchiveLinkLoader();
$contentArray = $contentLoader->getSideContent('A');
$currYear = null;
$currMonth = null;
$size = count($contentArray);
$index= 0;
$yearAdded = false;
$monthAdded = false;


echo '<div class="archiveTx">Archives</div>';

foreach ($contentArray as & $content)
{
	$index++;

	if($currYear != $content->getYear())
	{
		$currYear = $content->getYear();
		if ($index != 1)
		{
			echo '</div>';
		}

		if ($monthAdded == true)
		{
			if ($index != 1)
			{
				echo '</div>';
				$monthAdded = false;
			}
		}
		if ($index == 1)
		{
			echo '<div class="yearArch" onclick="toggle(id)" id="'.$content->getYear().'">&#9660;'.$content->getYear().'</div>';
			echo '<div id="m'.$content->getYear().'" style="display:block">';
		}
		else
		{
			echo '<div class="yearArch" onclick="toggle(id)" id="'.$content->getYear().'">&#9658;'.$content->getYear().'</div>';
			echo '<div id="m'.$content->getYear().'" style="display:none">';
		}

		//echo '<div id="m'.$content->getYear().'">';
	}


	if($currMonth != $content->getMonth())
	{
		$currMonth = $content->getMonth();
		if ($index != 1 && $monthAdded == true)
		{
			echo '</div>';
		}


		if ($index != 1)
		{
			echo '<div class="months" onclick="toggle(id)" id="'.$content->getMonth().$content->getYear().'">&#9658;'.$content->getMonth().'</div>';
			echo '<div style="display:none" id="m'.$content->getMonth().$content->getYear().'">';
		}
		else
		{
			echo '<div class="months" onclick="toggle(id)" id="'.$content->getMonth().$content->getYear().'">&#9660;'.$content->getMonth().'</div>';
			echo '<div style="display:block" id="m'.$content->getMonth().$content->getYear().'">';
		}


		$monthAdded = true;
	}

	echo '<div class="story" onclick=getStory('.$content->getStoryId().')> <a href="#">'.$content->getStoryTitle().'</a></div>';
	if ($index == $size )
	{
		echo '</div>';
	}
}
echo '</div>';
?>








